package c.e.a.b.e.c;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.StrictMode;
import android.os.StrictMode.ThreadPolicy;
import b.f.a;
import b.f.g.e;
import b.f.h;
import java.util.Iterator;
import java.util.Map;

/* compiled from: com.google.android.gms:play-services-measurement-impl@@18.0.0 */
public final class s2 implements b2 {
    public static final Map<String, s2> e = new a();
    public final SharedPreferences a;
    public final OnSharedPreferenceChangeListener b;
    public final Object c;
    public volatile Map<String, ?> d;

    public static s2 b(Context context) {
        if (w1.a()) {
            throw null;
        }
        s2 s2Var;
        synchronized (s2.class) {
            s2Var = (s2) ((h) e).get(null);
            if (s2Var != null) {
            } else {
                ThreadPolicy allowThreadDiskReads = StrictMode.allowThreadDiskReads();
                try {
                    throw null;
                } catch (Throwable th) {
                    StrictMode.setThreadPolicy(allowThreadDiskReads);
                }
            }
        }
        return s2Var;
    }

    public static synchronized void c() {
        Map map = e;
        synchronized (s2.class) {
            Iterator it = ((e) ((a) map).values()).iterator();
            while (it.hasNext()) {
                s2 s2Var = (s2) it.next();
                s2Var.a.unregisterOnSharedPreferenceChangeListener(s2Var.b);
            }
            ((h) map).clear();
        }
    }

    public final Object a(String str) {
        Map map = this.d;
        if (map == null) {
            synchronized (this.c) {
                map = this.d;
                if (map == null) {
                    ThreadPolicy allowThreadDiskReads = StrictMode.allowThreadDiskReads();
                    try {
                        Map all = this.a.getAll();
                        this.d = all;
                        map = all;
                    } finally {
                        StrictMode.setThreadPolicy(allowThreadDiskReads);
                    }
                }
            }
        }
        return map != null ? map.get(str) : null;
    }
}
